<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="f" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>

<div class="modal fade" id="modalLoginForm" tabindex="-1" role="dialog" data-backdrop="false">
    <div class="modal-dialog">
        <f:form id="loginFormId" cssClass="form-horizontal modal-content" action="${pageContext.request.contextPath}/j_spring_security_check" role="form">
            <%--<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />--%>
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Пожалуйста авторизуйтесь</h4>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <label class="col-md-4 control-label" for="userLogin">Логин</label>

                    <div class="col-lg-6">
                        <input type="text" id="userLogin" name="j_username" class="form-control"/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-md-4 control-label" for="userPassword">Пароль</label>

                    <div class="col-lg-6">
                        <div class="input-group ">
                            <input type="password" id="userPassword" name="j_password" class="form-control pwd"/>
                            <span class="input-group-btn">
                                <button class="btn btn-default reveal" type="button"><i class="glyphicon glyphicon-eye-open"></i></button>
                            </span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-offset-7 col-md-10">
                        <div class="checkbox">
                            <input type="checkbox" id="rememberUser"/>
                            <label class="" for="rememberUser">Запомнить</label>
                        </div>
                    </div>
                </div>
                <p>
                    <a href="<c:url value="/account/register"/>" class="dax" data-dismiss="modal" aria-hidden="false">Регистрация</a>, если у вас нет аккаунта.
                </p>
            </div>
            <div class="modal-footer">
                <input type="submit" value="Авторизация" class="btn btn-primary"/>
                <button type="button" class="btn btn-default" data-dismiss="modal">Отмена</button>
            </div>
        </f:form>
    </div>
</div>

<script type="text/javascript">
    $('#modalLoginForm').modal('show');
    //$.validator.unobtrusive.parse($("#loginFormId"));
    $('#loginFormId').find('.reveal').mousedown(function () {
        var inp = $(this).closest('.input-group').find('.pwd');
        inp.replaceWith(inp.clone().attr('type', 'text'));
    }).bind('mouseup mouseout', function () {
        var inp = $(this).closest('.input-group').find('.pwd');
        inp.replaceWith(inp.clone().attr('type', 'password'));
    });
</script>